<%@ page language="java" import="com.util.StringFinal" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css"
	href="../../bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="../../bootstrap-3.3.7/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css" />
<link rel="stylesheet" type="text/css" href="../../css/personal.css" />
<link rel="stylesheet" type="text/css" href="../../css/background.css" />
<link rel="stylesheet" type="text/css"
	href="../../css/upload/fileinput.css" />

<link href="../../css/bootstrap-datetimepicker.min.css" rel="stylesheet" />

<script type="text/javascript"
	src="../../bootstrap-3.3.7/dist/js/jquery.min.js"></script>
<script type="text/javascript"
	src="../../bootstrap-3.3.7/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../../js/upload/fileinput.js"></script>
<script type="text/javascript" src="../../js/upload/zh.js"></script>
<script type="text/javascript" src="../../js/login/jquery.form.min.js"></script>
<script type="text/javascript" src="../../js/dynamic.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link
	href="../../bootstrap-3.3.7/docs/assets/css/ie10-viewport-bug-workaround.css"
	rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<script src="../../js/moment-with-locales.js"></script>
<script src="../../js/bootstrap-datetimepicker.min.js"></script>
<script src="../../js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="../../js/wordcontrol.js"></script>
</head>
<body>
	<form class="form-horizontal" id="fm"
		enctype="application/x-www-form-urlencoded" method="post">
		<h4 class="heading">审核知识</h4>
		<div class="myline"></div>
		<div class="col-md-10">
			<div class="form-group">
				<input type="text" id="info_id" hidden="true" value="${id}"
					name="info_id"> <input type="text" id="info_url"
					hidden="true" name="info_url"> <br> <label
					class="col-md-2 control-label">篇名:</label>
				<div class="col-md-8">
					<input id="info_name" type="text" class="form-control"
						name="info_name">
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">作者:</label>
				<div class="col-md-9">
					<input id="info_author" type="text" class="form-control"
						name="info_author">
				</div>
				<!-- <div style="float: left">
					<span style="color: red;">必填</span>
				</div> -->
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">作者单位:</label>
				<div class="col-md-9">
					<input id="info_company" type="text" class="form-control"
						name="info_company">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">关键词:</label>
				<div class="col-md-8">
					<input id="info_keyword" type="text" class="form-control"
						name="info_keyword">
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">发布部门:</label>
				<div class="col-md-9">
					<input id="info_bm" type="text" class="form-control" name="info_bm">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">文献来源:</label>
				<div class="col-md-9">
					<input id="info_source" type="text" class="form-control"
						name="info_source">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">发布日期:</label>
				<div class="col-md-9">
					<input id="info_time" type="text" class="form-control"
						name="info_time">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">库类别:</label>
				<div class="col-md-10" id="ku" class="row"></div>
			</div>
			<div class="form-group" id="tag"></div>
			<div class="form-group">
				<label class="col-md-2 control-label">文号:</label>
				<div class="col-md-7">
					<input id="info_wh" type="text" class="form-control" name="info_wh">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">摘要:</label>
				<div class="col-md-9">
					<textarea id="info_abstract" name="info_abstract"
						onKeyUp="ControlWordCount(&quot;info_abstract&quot;,&quot;count&quot;,<%=StringFinal.information_length%>)"
						cols="30" rows="4" class="form-control"></textarea>
					<p style="float: right; margin-top: 5px">
						你还可以输入<span id="count"><%=StringFinal.information_length%></span>个字
					</p>
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">下载:</label>
				<div class="col-md-10" style="margin-top: 8px;">
					<a href="javascript:download()" onclick=""><span
						id="download_name" class="text-primary" style="font-weight: bold"></span></a>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">提示:</label>
				<div class="col-md-10">
					<label class="radio-inline"> <input type="radio" value="no"
						name="modify" checked="true">下载的知识文件内容没有修改
					</label> <label class="radio-inline"> <input type="radio"
						value="yes" name="modify">下载的知识文件内容进行了修改
					</label>
				</div>
			</div>
			<div class="form-group" id="uploaddiv" hidden>
				<label class="col-md-2 control-label">重新上传:</label>
				<div class="col-md-7">
					<input id="fileinput" name="fileinput" type="file">
				</div>
			</div>
		</div>
	</form>
	<div class="row">
		<div class="col-md-3"></div>
		<div class="col-md-6">
			<button type="button" class="btn  btn-info" id="checkAgree"
				onclick="submitForm()">审核通过</button>
			<button type="button" class="btn  btn-info" id="checkNogree"
				style="margin-left: 30px" onclick="deleForm()">审核不通过</button>
		</div>
	</div>

</body>




<script>
	
    var countt=<%=StringFinal.information_length%>;
	var urL = "../information/updateCheckInfo";
	function download() {
		var filename = $('#info_url').val();
		var infoid = $('#info_id').val();
		var status = "未审核";
		window.location.href = encodeURI("../information/p_downloadn?filename=" + filename
				+ "&infoid="+infoid+"&status="+status);
	}
	$(function() {
		/* //获取rootku下拉框中的值
		KuBind("ku1", 1, "");
		//根据rootku中的值初始化相应子库
		dynamicKu("addku", $("#ku1").val());
		//根据rootku中的值初始化下面的标签下拉框
		TagBind("tag", $("#ku1").val());
		//绑定事件
		$("#ku1").change(function() {
			KuBind("ku2", 2, $("#ku1").val());
			TagBind("tag", $("#ku1").val());
			dynamicKu("addku", $("#ku1").val());
		}); */
		KuBindNew("kudiv", "ku", 1, "");

		dynamicBindNew("kudiv", "ku", 1);
		
		TagBind("tag", $("#ku1").val());
		//请求页面初始化数据
		$.ajax({
			async : false,
			cache : false,
			type : 'POST',
			dataType : "json",
			data : {
				"info_id" : $('#info_id').val()
			},
			url : "../information/getInformationByID",
			error : function() {
				alert('请求失败');
			},
			success : function(data) {
				if (data != null) {
					$('#info_name').val(data.info_name);
					$('#info_author').val(data.info_author);
					$('#info_company').val(data.info_company);
					$('#info_keyword').val(data.info_keyword);
					$('#info_bm').val(data.info_bm);
					$('#info_time').val(data.info_time);
					$('#info_source').val(data.info_source);
					$('#info_wh').val(data.info_wh);
					if(data.info_abstract!=null){
						$('#info_abstract').val(data.info_abstract.replace(/&nbsp/g," ").replace(/<br>/g,"\n"));
						$('#count').text(countt-data.info_abstract.length);
					}		
					$('#info_url').val(data.info_url);
					var url = data.info_url;
					var names = url.split("_", 2);
					$('#download_name').html(names[names.length - 1]);
					
				}
			}
		});//AJAX结束 

		fileinput();
		datetime();

		$("input[type='radio']").click(function() {
			//不上传
			if ($("input[type='radio']:checked").val() == "no") {
				$("#fm").attr("entype", "application/x-www-form-urlencoded");
				urL = "../information/updateCheckInfo";
				$("#uploaddiv").hide();
			}
			//上传文件
			else {
				$("#fm").attr("entype", "multipart/form-data");
				urL = "../information/updatefileCheckInfo";
				$("#uploaddiv").show();
			}

		});
	});

	function datetime() {
		$('#datetime').datetimepicker({
			language : 'zh-CN',//显示中文
			format : 'yyyy-mm-dd',//显示格式
			minView : "month",//设置只显示到月份
			initialDate : new Date(),
			autoclose : true,//选中自动关闭
			todayBtn : true,//显示今日按钮
			locale : moment.locale('zh-cn')
		});

	}
	function fileinput() {
		$("#fileinput").fileinput({
			browseLabel : '选择文件',
			language : 'zh', //设置语言
			showPreview : false,
			allowedFileExtensions : ['doc', 'pdf', 'docx'],//接收的文件后缀
			showUpload : false, //是否显示上传按钮
			showCaption : true,//是否显示标题
			browseClass : "btn btn-primary", //按钮样式  
			uploadAsync : false, //默认异步上传
			maxFileSize : 1024,//单位为kb，如果为0表示不限制文件大小
			minFileCount : 0,
			maxFileCount : 20, //表示允许同时上传的最大文件个数
			enctype : 'multipart/form-data',
			validateInitialCount : true,
			msgFilesTooMany : "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
			language : 'zh',
		});
	}
	function submitForm() {
		var name = $('#info_name').val();
		var keyword = $('#info_keyword').val();
		var infoabs = $("#info_abstract").val();
		if (name == null || name == "" ||  keyword == null || keyword == "" || infoabs == null
				|| infoabs == "") {
			alert("存在未输入的必填项");
			return;
		}
		var kulist = $("select[name='kulist'] option:selected");
		var kudata = kulist[kulist.length - 1].value;

		var tagstr = "";
		var i = 0;
		$("select[name='taglist'] option:selected").each(function() {
			if (i == 0)
				tagstr += $(this).text();
			else
				tagstr += ";" + $(this).text();
			i++;
		});
		$("#checkAgree").attr("disabled", true);
		if ($("input[type='radio']:checked").val() == "yes") {
			if ($("#fileinput").val() =="" ||$("#fileinput").val() == null) {
				alert("请输入文件");
				$("#checkAgree").attr("disabled", false);
				return;
			}
		}
		$("#fm").ajaxSubmit({
			url : urL,
			data : {
				first_class : kudata,
				info_tag : tagstr
			},
			success : function(result) {
				if (result == 1) {
					alert("审核成功");
					$("#refresh").load("../information/getExamineview");
				} else {
					alert("审核失败,有可能是生成预览失败导致的");
					$("#checkAgree").attr("disabled", false);
				}

			}
		});

	}

	function deleForm() {
		$("#checkNogree").attr("disabled", true);
		$.ajax({
			url : "../information/delCheckInformation",
			data : {
				info_id : $('#info_id').val(),
				info_url : $('#info_url').val()
			},
			async : true,
			success : function(result) {
				if (result == 1) {
					alert("审核成功");
					$("#refresh").load("../information/getExamineview");
				} else {
					alert("审核失败");
					$("#checkNogree").attr("disabled", false);
				}
			}
		});
	}
</script>
</html>